set scheme s2color

** Figure 2(a)
use "$project_path/data/4_regdata/regdata", clear
rdrobust treatment_alt runvar if Type_Election=="Parliamentary", all
local rdd_tau : di %8.3f e(tau_cl)
local rdd_lb : di %8.3f e(ci_l_rb)
local rdd_lb = subinstr("`rdd_lb'", " ", "", .)
local rdd_ub : di %8.3f e(ci_r_rb)
local rdd_ub = subinstr("`rdd_ub'", " ", "", .)
local rdd_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local rd_est = "RD est.: `rdd_tau' [`rdd_lb', `rdd_ub'] (95% CI). p-value: `rdd_pval'"
rdplot treatment_alt runvar if inrange(runvar, -20, 20) & Type_Election=="Parliamentary", nbins(10 10)  p(1) graph_options(xtitle("Margin of victory of the challenger", size(large)) graphregion(color(white)) note("`rd_est'", tstyle(size(medlarge))) ylabel(0(.2)1, angle(0) labsize(large)) xlabel(-20(5)20, labsize(large)) legend(off) xscale(range(-20 20)) title("Probability of turnover in the executive branch", size(large) placement(9) span))
graph export "$project_path/output/figures/Figure_2a.pdf", as(pdf) name("Graph") replace

** Figure 2(b)
use "$project_path/data/4_regdata/regdata", clear
rdrobust treatment_alt runvar, all
local rdd_tau : di %8.3f e(tau_cl)
local rdd_lb : di %8.3f e(ci_l_rb)
local rdd_lb = subinstr("`rdd_lb'", " ", "", .)
local rdd_ub : di %8.3f e(ci_r_rb)
local rdd_ub = subinstr("`rdd_ub'", " ", "", .)
local rdd_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local rd_est = "RD est.: `rdd_tau' [`rdd_lb', `rdd_ub'] (95% CI). p-value: `rdd_pval'"
rdplot treatment_alt runvar if inrange(runvar, -20, 20), nbins(10 10)  p(1) graph_options(xtitle("Margin of victory of the challenger", size(large)) graphregion(color(white)) note("`rd_est'", tstyle(size(medlarge))) ylabel(0(.2)1, angle(0) labsize(large)) xlabel(-20(5)20, labsize(large)) legend(off) xscale(range(-20 20)) title("Probability of turnover in the executive branch", size(large) placement(9) span))
graph export "$project_path/output/figures/Figure_2b.pdf", as(pdf) name("Graph") replace

